package com.qf.java2207.no3_teamproject_springboot_01.controller;
//须知少时凌云志，曾许人间第一流



import com.qf.java2207.no3_teamproject_springboot_01.common.R;
import com.qf.java2207.no3_teamproject_springboot_01.pojo.SecurityManagement;
import com.qf.java2207.no3_teamproject_springboot_01.service.SecurityManagementService;
import com.qf.java2207.no3_teamproject_springboot_01.vo.LayuiPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
@RestController
@RequestMapping("/management")
public class SecurityManagementController {

    @Autowired
    private SecurityManagementService securityManagementService;



    @RequestMapping("/managementList")
    //public LayuiPageVo<SecurityManagement> securityManagementPageData(Integer page,Integer limit){
    // 注意 这里的  @RequestParam 不能省略   省略的话就不能获取参数了
    public LayuiPageVo<SecurityManagement> securityManagementPageData(@RequestParam Map<String,Object> params){
        System.out.println(params);
        //return securityManagementService.securityManagementPageData(page,limit);
        return securityManagementService.securityManagementPageData(params);
    }



    // 这个请求  会匹配到 预检请求
    @GetMapping("/deleteSecurityManagement")
    public R deleteSecurityManagement(Integer id){
        //根据Id删除学生信息
        int result = securityManagementService.deleteSecurityManagement(id);
        if(result==1){
            return R.ok();
        }else{
            return R.error();
        }
    }

//    @GetMapping("/deleteSecurityManagementsByIds")
//    public R deleteSecurityManagementsByIds(String ids){
//        //根据Id删除学生信息
//////        int result = securityManagementService.deleteSecurityManagementsByIds(id);
////        if(result>0){
////            return R.ok();
////        }else{
////            return R.error();
////        }
//    }

    @RequestMapping("/updateSecurityManagement")
    public R updateSecurityManagement(SecurityManagement securityManagement){
        System.out.println(securityManagement);

        int result = securityManagementService.updateSecurityManagement(securityManagement);
        if(result==1){
            return R.ok();
        }else{
            return R.error();
        }

    }


    @RequestMapping("/addSecurityManagement")
    public R addSecurityManagement(SecurityManagement securityManagement){
        System.out.println(securityManagement);

        int result = securityManagementService.addSecurityManagement(securityManagement);
        if(result==1){
            return R.ok();
        }else{
            return R.error();
        }

    }

}
